<template>
  <div class="cat-item-container">
    <div class="img-wrapper">
      <img v-if="cat.imgUrl" :src="cat.imgUrl.split(',')[0]" :title="cat.name" />
      <div v-else style="line-height: 180px; text-align: center; font-weight: bold; font-size: 26px; color: #aaa">
        暂无图片
      </div>
    </div>
    <div class="desc">{{ props.cat.name }}</div>
  </div>
</template>

<script setup lang="ts">
const props = defineProps(["cat"]);
</script>

<style scoped lang="scss">
@import "@/css/respondMixin";

.cat-item-container {
  .img-wrapper {
    width: 180px;
    height: 180px;
    border: 4px solid #fff;
    background-image: linear-gradient(#fef3d3, #ffffff);
    box-shadow: 0px 0 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;

    @include respond-to("phone") {
      width: 5rem;
      height: 5rem;
    }

    &:hover {
      border-color: #009688;
      img {
        transform: translateX(0px);
      }
    }

    img {
      object-fit: cover;
      width: 100%;
      height: 100%;
      transform: translateX(-20px);
      transition: 0.25s;

      @include respond-to("phone") {
        transform: none;
      }
    }
  }
  .desc {
    font-weight: 200;
    margin-top: 2px;
    text-align: center;
  }
}
</style>
